<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <title>HelpDo</title>
    <meta name="keywords" content="HelpDo管理系统">
    <meta name="description" content="HelpDo管理系统">
    <link href="/css/bootstrap.min.css" rel="stylesheet">
    <link href="/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css" rel="stylesheet">
    <link href="/css/login.css" rel="stylesheet">
    <!--[if lt IE 9]>
    <meta http-equiv="refresh" content="0;ie.html"/>
    <![endif]-->
    <style type="text/css">
        body.signin{
            position: relative;
            /*background: url(../img/background_register.jpg) no-repeat center fixed;*/
        }
        .signinpanel {
            width: 912px;
            margin: 38px auto 0 auto;

            position: absolute;
            left: 0;
            right: 0;
            top: 0;
            bottom: 0;
            background:rgba(255,255,255,0.3);
        }
        .form-horizontal .form-group {
            margin-right: -15px;
            margin-left: -15px;
            margin-bottom: 10px;
            display: flex;
            align-items: center;
        }
        .row{
            margin-right: 0px;
            margin-left: 0px;
        }
        .row .yzm{
            display: flex;
            justify-content: center;
        }
        .signinpanel .signin-info ul li{
            margin-bottom: 6px;
        }
    </style>
    <script>
        if (window.top !== window.self) {
            window.top.location = window.location;
        }
    </script>

</head>

<body class="signin">
<div class="signinpanel">
    <div class="row">
        <div class="col-sm-6">
            <div class="signin-info">
                <div class="logopanel m-b">
                    <h1>HelpDo</h1>
                </div>
                <div class="m-b"></div>
                <h3>
                    欢迎使用 <strong>校友帮办在线平台</strong>
                </h3>
                <ul class="m-b">
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        校友帮办
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 安全放心</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i> 快捷便利</li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        沟通顺畅
                    </li>
                    <li><i class="fa fa-arrow-circle-o-right m-r-xs"></i>
                        省时省力又省心
                    </li>
                </ul>
            </div>
        </div>
        <div class="col-sm-6">
                    <form class="form-horizontal m-t" id="signupForm" style="padding: 10px">
                        <input id="userId" name="userId" type="hidden">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">姓名：</label>
                            <div class="col-sm-8">
                                <input id="name" name="name" class="form-control" type="text"  autocomplete="off" value="李大水">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">用户名：</label>
                            <div class="col-sm-8">
                                <input id="username" name="username" class="form-control"
                                    type="text" autocomplete="off" value="dog">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">密码：</label>
                            <div class="col-sm-8">
                                <input id="password" name="password" class="form-control"
                                    type="password" value="111111">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">确认密码：</label>
                            <div class="col-sm-8">
                                <input id="password2" name="password2" class="form-control"
                                    type="password" value="111111">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">入学年份：</label>
                            <div class="col-sm-8">
                                <input id="grade" name="grade" class="form-control"
                                    type="text" autocomplete="off" value="2010">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">就读学院：</label>
                            <div class="col-sm-8">
                                <input id="college" name="college" class="form-control"
                                    type="text" autocomplete="off" value="软件学院">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">所学专业：</label>
                            <div class="col-sm-8">
                                <input id="major" name="major" class="form-control"
                                    type="text" autocomplete="off" value="软件工程">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">E-mail：</label>
                            <div class="col-sm-8">
                                <input id="email" name="email" class="form-control"
                                    type="email" autocomplete="off" value="pig@126.com">
                            </div>
                        </div>
                        <div class="form-group hidden">
                            <label class="col-sm-3 control-label">手机号：</label>
                            <div class="col-sm-8">
                                <input id="mobile" name="mobile" class="form-control"
                                    type="text" autocomplete="off">
                            </div>
                        </div>
                        <div class="form-group hidden">
                            <label class="col-sm-3 control-label">状态:</label>
                            <div class="col-sm-8">
                                <label class="radio-inline"> <input type="radio"
                                    name="status" value="1" checked/> 正常
                                </label> <label class="radio-inline"> <input type="radio"
                                    name="status" value="0" /> 禁用
                                </label>
                            </div>
                        </div>
                        <input type="hidden" name="roleIds" id="roleIds" value="59">
                        <div class="form-group hidden">
                            <label class="col-sm-3 control-label">角色</label>
                            <div class="col-sm-8">
                                <input name="role" type="checkbox">
                            </div>
                        </div>
                        <div class="row yzm">
                            <div class="col-xs-5 pull_left">
                                <div class="form-group">
                                    <input class="form-control" type="tel" name="verify" id="verify" autocomplete="off" placeholder="请输入验证码" maxlength="4">
                                </div>
                            </div>
                            <div class="col-xs-5 pull_left">
                                <a href="javascript:void(0);" rel="external nofollow" title="点击更换验证码">
                                    <img style="margin-top: 12px;" id="imgVerify" src="" alt="更换验证码" height="36" width="100%" onclick="getVerify(this);">
                                </a>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button id="register" type="submit" class="btn btn-primary" style="width: 200px">提交</button>
                            </div>
                        </div>
                    </form>
        </div>
    </div>
    <div class="signup-footer">
        <div class="pull-left">&copy; 2017 All Rights Reserved. HelpDo
        </div>
    </div>
</div>
<script th:inline="javascript"> var ctx = [[@{/}]] ; </script>
<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4" th:src="@{/js/jquery.min.js?v=2.1.4}"></script>
<script src="/js/bootstrap.min.js?v=3.3.6" th:src="@{/js/bootstrap.min.js?v=3.3.6}"></script>

<!-- 自定义js -->
<script src="/js/content.js?v=1.0.0" th:src="@{/js/content.js?v=1.0.0}"></script>

<!-- jQuery Validation plugin javascript-->
<script src="/js/ajax-util.js"></script>
<script src="/js/plugins/validate/jquery.validate.min.js"
        th:src="@{/js/plugins/validate/jquery.validate.min.js}"></script>
<script src="/js/plugins/validate/messages_zh.min.js" th:src="@{/js/plugins/validate/messages_zh.min.js}"></script>
<script src="/js/plugins/layer/layer.min.js" th:src="@{/js/plugins/layer/layer.min.js}"></script>
<script type="text/javascript">
    $(document).ready(function () {
        validateRule();
        $("body").keydown(keyDownLogon);
        // getVerify($("#imgVerify"));
        $("#imgVerify").click()
    });

    $.validator.setDefaults({
        submitHandler: function () {
            register();
        }
    });

    function register() {
        $.ajax({
            type: "POST",
            url: ctx + "ajaxRegister",
            data: $('#signupForm').serialize(),
            success: function (r) {
                debugger;

                if (r.code == 0) {
                    var index = layer.load(1, {
                        shade: [0.1, '#fff'] //0.1透明度的白色背景
                    });
                    parent.location.href = '/index';
                } else {
                    layer.msg(r.msg);
                }
            },
        });
    }

    function keyDownLogon() {
        if (event.keyCode == "13") {
            $("#register").trigger('click');
        }
    }

    function validateRule() {
        var icon = "<i class='fa fa-times-circle'></i> ";
        $("#signupForm").validate({
            rules: {
                name: {
                    required: true
                },
                username: {
                    required: true
                },
                password: {
                    required: true,
                    minlength:6
                },
                password2: {
                    required: true,
                    minlength:6,
                    equalTo: "#password"
                },
                grade: {
                    required: true
                },
                college: {
                    required: true
                },
                major: {
                    required: true
                }
            },
            messages: {
                username: {
                    required: icon + "请输入您的用户名",
                },
                password: {
                    required: icon + "请输入您的密码",
                }
            }
        })
    }

    //获取验证码
    function getVerify(obj) {
        obj.src = "/getVerify?" + Math.random();
        //console.log(obj)
    }
</script>
</body>
</html>
